requireViewById

open fun <T : View?> requireViewById(@NonNull window: Window, @IdRes id: Int): T(source)

Finds a view that was identified by the android:id XML attribute that was processed in onCreate, or throws an IllegalArgumentException if the ID is invalid, or there is no matching view in the hierarchy.

Note: In most cases -- depending on compiler support -- the resulting view is automatically cast to the target class type. If the target class type is unconstrained, an explicit cast may be necessary.

Return

a view with given ID

Parameters

window

window in which to find the view.

id

the ID to search for

See also